
import { HeartOutlined, HeartFilled } from '@ant-design/icons'
import styles from './style.less';
import { docLike } from '@/services/doc/common'


const LikeIcon = (props) => {
    const {
        projectId,
        isLike,
        docId,
        docType,
        likeCnt,
        onLikeChange,
    } = props;

    const likeDoc = () => {
        let changeLike = isLike === 1 ? 0 : 1
        docLike(projectId, docType, docId, changeLike).then(result => {
            if (onLikeChange) {
                onLikeChange({
                    isLike: changeLike,
                })
            }
        })
    }

    if (isLike) {
        return <div className={styles.likeClassName} onClick={likeDoc}>
            <HeartFilled style={{ color: "#ff4c4c" }} /> {likeCnt}
        </div>
    }


    return <div className={styles.likeClassName} onClick={likeDoc}>
        <HeartOutlined /> {likeCnt}
    </div>
}

export default LikeIcon